﻿@using Webdiyer.WebControls.Mvc

@model PagedList<WebShop.Contracts.Product>

<div id="dvProducts">
    <table>
        <tr>
            <th>
                ProductName
            </th>
            <th>
                Suppliers
            </th>
            <th>
                Categories
            </th>
            <th>
                QuantityPerUnit
            </th>
            <th>
                UnitPrice
            </th>
            <th>
                UnitsInStock
            </th>
            <th>
                UnitsOnOrder
            </th>
            <th>
                Discontinued
            </th>
            <th></th>
        </tr>

    @foreach (var item in Model) {
        <tr>
            <td>
                @Html.ActionLink(item.ProductName, "Details", "Products", new { id = item.ProductID }, new { title = "View products details for: " + item.ProductName })
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Supplier.CompanyName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Category.CategoryName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.QuantityPerUnit)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UnitPrice)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UnitsInStock)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.UnitsOnOrder)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Discontinued)
            </td>
        </tr>
    }
    </table>

    <p>
       @Html.AjaxPager(Model, null, new { q = ViewBag.q },new PagerOptions() { PageIndexParameterName = "pageIndex", ShowDisabledPagerItems = false, AlwaysShowFirstLastPageNumber = true }, new AjaxOptions { UpdateTargetId = "dvProducts" })
    </p>
</div>